package com.gxsf.wechatbook.util;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author BeijiRonin
 * @version 1.0.0
 * @date 2021/1/21 20:14
 */
public class DateUtil {
    /**
     * 验证是否存在这个时间段内
     * <p>
     * 格式：08:00 09:00
     *
     * @param starDate star date
     * @param endDate  end date
     * @return
     */
    public static boolean dateVer(String starDate, String endDate) {
        //当前时间
        String nowDate = new SimpleDateFormat("HH").format(System.currentTimeMillis());
        String[] split = starDate.split(":");
        String aimsH = split[0];

        String[] split2 = endDate.split(":");
        String aimsH2 = split2[0];

        int nowHourInt = Integer.parseInt(nowDate);
        int aimsHourInt = Integer.parseInt(aimsH);
        int aimsHourInt2 = Integer.parseInt(aimsH2);
        return nowHourInt >= aimsHourInt && nowHourInt < aimsHourInt2;
    }

    public static boolean dateVer(Timestamp starTime, Timestamp endTime) {
        String[] starTimeFormat = new SimpleDateFormat("yyyy MM dd hh mm ss").format(starTime).split(" ");
        String[] endTimeFormat = new SimpleDateFormat("yyyy MM dd hh mm ss").format(endTime).split(" ");
        return false;
    }

    /**
     * 获得今天早上八点的格式化时间
     *
     * @return
     */
    public static String get8Format() {
        Date date = new Date();
        date.setDate(date.getDate());
        date.setHours(8);
        date.setMinutes(0);
        date.setSeconds(0);

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return simpleDateFormat.format(date);
    }

    public static Date get8Date() {
        Date date = new Date();
        date.setDate(date.getDate());
        date.setHours(8);
        date.setMinutes(0);
        date.setSeconds(0);
        return date;
    }
}
